home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / rwvector.lha / RWVector2.1 / rw / DoubleFFT.h < prev    next >
C/C++ Source or Header  |  1989-08-18  |  3KB  |  95 lines

  1. #ifndef DOUBLEFFT_H
  2. #define DOUBLEFFT_H
  3. #pragma once
  4.  
  5. /*
  6.  *    Double Precision FFT server
  7.  *
  8.  *    Copyright (C) 1988, 1989.
  9.  *
  10.  *    Dr. Thomas Keffer
  11.  *    Rogue Wave Associates
  12.  *    P.O. Box 85341
  13.  *    Seattle WA 98145-1341
  14.  *
  15.  *    Permission to use, copy, modify, and distribute this
  16.  *    software and its documentation for any purpose and
  17.  *    without fee is hereby granted, provided that the
  18.  *    above copyright notice appear in all copies and that
  19.  *    both that copyright notice and this permission notice
  20.  *    appear in supporting documentation.
  21.  *    
  22.  *    This software is provided "as is" without any
  23.  *    expressed or implied warranty.
  24.  *
  25.  *
  26.  *    @(#)DoubleFFT.h    2.1    8/18/89
  27.  */
  28.  
  29. #include "DComplexFFT.h"
  30.      
  31. /*
  32.  
  33. This class does fourier transforms involving a real sequence.  It is
  34. derived from class DComplexFFTServer.
  35.  
  36. Let V(j), j=0,1,...,2N-1 be a 2N points long real sequence.  Its
  37. transform will be complex conjugate even.  That is, C(n) ==
  38. conj(C(-n)) or C(n) == conj(C(2N-n)).
  39.  
  40. The routine fourier() returns the lower half of this complex conjugate
  41. even sequence, that is C(n), n=0,..,N.  The upper half can be
  42. recovered from the relationship C(n) == C(2N-n).  Note that the
  43. requirement that the length of the original sequence be 2N means that
  44. V must have an even number of points.  The resulting complex conjugate
  45. even sequence C(n) will have N + 1 complex points, for a total of 2N+2
  46. points.  The extra two points are the imaginary parts of C(0) and
  47. C(N).  Both are always zero.  The transform calculated is:
  48.  
  49.                 2N-1
  50.          C(n) = sum V(j) exp(-pi * n * j * I / 2N); n=0,...,2N-1
  51.                 j=0
  52.  
  53. Given the lower half of C(n), the routine ifourier() calculates the
  54. Inverse Fourier transform (IDFT):
  55.  
  56.                 2N-1
  57.          V(j) = sum C(n) exp( pi * n * j * I / 2N); j=0,...,2N-1
  58.                 n=0
  59.  
  60. Note that the transform is not normalized: calling fourier(), followed
  61. by ifourier() will leave the series multiplied by 2N.  
  62.  
  63. The server is set up to do a transform for a specified N.  This can
  64. either be specified at construction time, by using functionw
  65. setOrder(), or (the easiest!) let it figure it out for itself from
  66. the length of the sequence handed to it.  If the series length
  67. changes, it will automagically reconfigure.
  68.  
  69. */
  70.  
  71. class DoubleFFTServer : public DComplexFFTServer{
  72.   unsigned        server_N;
  73.   DComplexVec        roots_of_1;
  74.   DComplexVec        conjroots_of_1;
  75. protected:
  76.   void            checkEven(int);
  77. public:
  78.   DoubleFFTServer();
  79.   DoubleFFTServer(unsigned oforder);
  80.   DoubleFFTServer(const DoubleFFTServer&);
  81.  
  82.   void            operator=(const DoubleFFTServer&);
  83.  
  84.   unsigned        order()    {return server_N;}
  85.   void            setOrder(unsigned); // Set new server_N;
  86.  
  87.   /***********  TRANSFORMS ***********/
  88.   // Returns DFT of a real sequence, which is a conjugate even sequence:
  89.   DComplexVec        fourier(const DoubleVec&);
  90.   // Returns IDFT of a complex conjugate even sequence, which is a real sequence:
  91.   DoubleVec        ifourier(const DComplexVec& v);
  92. };
  93.  
  94. #endif
  95.